﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Net.Mail;

namespace Marbles.Core.Web.Mail
{
    public class HtmlMailMessage : MailMessage
    {

        public HtmlTextWriter Writer
        {
            get { return this._writer; }
        }

        public string BodyHtml
        {
            get { return this._swriter.ToString(); }
        }

        private StringWriter _swriter = null;
        private HtmlTextWriter _writer = null;

        public HtmlMailMessage()
            : base()
        {
            this.IsBodyHtml = true;
            InitialiseWriter();
        }

        public HtmlMailMessage(MailAddress from, MailAddress to)
            : base(from, to)
        {
            this.IsBodyHtml = true;
            InitialiseWriter();
        }

        public HtmlMailMessage(string from, string to)
            : base(from, to)
        {
            this.IsBodyHtml = true;
            InitialiseWriter();
        }

        public HtmlMailMessage(string from, string to, string subject, string body)
            : base(from, to, subject, body)
        {
            this.IsBodyHtml = true;
            InitialiseWriter();
        }

        private void InitialiseWriter()
        {
            this._swriter = new StringWriter();
            this._writer = new HtmlTextWriter(this._writer);
        }
    }
}
